package com.darlingda.dahaigui.config;

import com.darlingda.dahaigui.constant.AIConst;
import com.volcengine.ark.runtime.service.ArkService;
import lombok.Data;
import okhttp3.ConnectionPool;
import okhttp3.Dispatcher;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;


/**
 * @Author: zheng
 * @Date: 2025/03/28 14:56
 */
@Configuration
@ConfigurationProperties(prefix = "ai")
@Data
public class AIConfig {
    
    private String apiKey;
    
    /**
     * 初试化 AI 客户端
     *
     * @return ArkService
     */
    @Bean
    public ArkService getArkService() {
        ConnectionPool connectionPool = new ConnectionPool(5, 1, TimeUnit.SECONDS);
        Dispatcher dispatcher = new Dispatcher();
        return ArkService.builder()
                .dispatcher(dispatcher)
                .connectionPool(connectionPool)
                .baseUrl(AIConst.BASE_URL)
                .apiKey(apiKey)
                .build();
    }
    
    
}
